<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f"%>
<%@ page import="java.util.List"%>
<%@ page isELIgnored="false" %> <%--isELIgnored=true禁用EL表达式--%>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/layui-v2.6.13/layui/css/layui.css" />
        <script type="text/javascript" src="<%=request.getContextPath() %>/layui-v2.6.13/layui/layui.js"></script>
        <script src="<%=request.getContextPath() %>/js/jquery.min-2.1.1.js"></script>
        <script src="https://eqcn.ajz.miesnfu.com/wp-content/plugins/wp-3d-pony/live2dw/lib/L2Dwidget.min.js"></script>

        <script>
            L2Dwidget.init({
                "model": {
                    "jsonPath": "https://unpkg.com/live2d-widget-model-shizuku@1.0.5/assets/shizuku.model.json",
                    "scale": 1
                },
                "display": {
                    "position": "right",
                    "width": 50,
                    "height": 100,
                    "hOffset": 0,
                    "vOffset": -20
                },
                "mobile": {
                    "show": true,
                    "scale": 0.5
                },
                "react": {
                    "opacityDefault": 0.7,
                    "opacityOnHover": 0.2
                }
            });
        </script>
		<style>
			table{
				border-collapse: collapse;/* 边框合并 */
			}
			th,td{
				border: 1px solid black;
				width: 80px;
			}
			.div1{
				margin-bottom: 20px;
			}
		</style>
	</head>

<body>
	<div style="padding: 20px;">
		<div>
			<form class="layui-form" id="selectForm">
			    <div class="div1">
                    <div class="layui-inline">
                        <input type="text" class="layui-input" placeholder="商品名称" name="">
                    </div>
                    <div class="layui-inline" padding:"0px 0px 0px 10px">
                        <select name="aId" lay-filter="filter">
                            <option value="">订单状态</option>
                            <option value="1">待付款</option>
                            <option value="2">代发货</option>
                            <option value="3">已发货</option>
                            <option value="4">已签收</option>
                            <option value="5">退款中</option>
                            <option value="6">已退款</option>
                            <option value="7">交易结束</option>
                        </select>
                    </div>
                    <div class="layui-inline">
                    <button type="submit" class="layui-btn layui-btn-radius layui-btn-primary" >查询</button>
                    </div>
				</div>


			</form>

		</div>

		<div>
		    <div><button class="layui-btn layui-btn-primary " onclick="getAllCheckedShipments()">一键发货</button></div>
		    <table class="layui-table">
				<colgroup>

					<col width="200">
					<col width="200">
					<col width="200">
					<col width="200">
					<col width="200">
					<col width="200">
					<col>
				</colgroup>
				<thead>
					<tr>
						<th><input type="checkbox" onclick="checkAll(this)" /></th>
						<th>订单号</th>
						<th>用户id</th>
						<th>用户名</th>
						<th>交易金额</th>
						<th>交易时间</th>
						<th>订单状态</th>
						<th>订单详情</th>
					</tr>
				</thead>
				<tbody>
                    <c:forEach items="${list}" var="list">
                        <tr>
                            <td><input type="checkbox" name="k" value="${list.orderNo}"></td>
                            <td>${list.orderNo}</td>
                            <td>${list.uId}</td>
                            <td>${list.uName}</td>
                            <td>${list.orderMoney}</td>
                            <td>${list.createTime}</td>
                            <td>
                                <c:if test="${list.orderStatus==1}">待付款</c:if>
                                <c:if test="${list.orderStatus==2}">待发货</c:if>
                                <c:if test="${list.orderStatus==3}">待签收</c:if>
                                <c:if test="${list.orderStatus==4}">已签收</c:if>
                                <c:if test="${list.orderStatus==5}">退款中</c:if>
                                <c:if test="${list.orderStatus==6}">已退款</c:if>
                                <c:if test="${list.orderStatus==7}">交易结束</c:if>
                            </td>
                            <td>
                                <a href="queryByOrderNo?orderNo=${list.orderNo}" target="main">详情</a>
                            </td>
                        </tr>
                    </c:forEach>


				</tbody>
			</table>
			<div style="text-align: center;">
                <button onclick="queryByPageNo(1,${totalPage})" class="layui-btn layui-btn-primary">首页</button>
                <button onclick="queryByPageNo(${pageNo-1},${totalPage})" class="layui-btn layui-btn-primary">上一页</button>
                <span>${pageNo} / ${totalPage}页</span>
                <button onclick="queryByPageNo(${pageNo+1},${totalPage})" class="layui-btn layui-btn-primary">下一页</button>
                <button onclick="queryByPageNo(${totalPage},${totalPage})" class="layui-btn layui-btn-primary">尾页</button>
            </div>
		</div>

	</div>
	<script>
	    function queryByPageNo(pageNo,totalPage){
            var params = $("#selectForm").serialize()
            console.info(params);
            if(pageNo < 1) pageNo=1;
            if(pageNo >totalPage) pageNo -=1;

            window.location.href="query?"+params+"&pageNo="+pageNo;
        }
         function checkAll(obj){
            var a = $(obj).prop("checked");
            if(a){
                $(":checkbox[name='k']").prop("checked", true);
            } else {
                $(":checkbox[name='k']").prop("checked", false);
            }
        }

        function getAllCheckedShipments(){
            var es = $(":checkbox[name='k']:checked");
            var params = "";
            $.each(es, function(index, item){
                console.info(item.value);
                params+=item.value+",";
            })
            console.info(params.substr(0, params.length-1));
            window.location.href="shipment?orderNo="+params.substr(0, params.length-1);

        }
	</script>
</body>

</html>